package com.museum.controller;


import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.entity.Damage;
import com.museum.service.DamageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Ruiwen
 * @since 2021-04-15
 */
@RestController
@RequestMapping("/damage")
@Api(tags = "damageService")
public class DamageController extends BaseApiService<JSONObject> {
    @Autowired
    private DamageService damageService;

    @ApiOperation(value = "添加damageService")
    @PostMapping("/add")
    public BaseResponse<JSONObject> cirAdd(Damage damage) {
        boolean save = damageService.save(damage);
        return save ? setResultSuccess("添加成功！") : setResultError("添加失败！");
    }

    @ApiOperation(value = "删除damageService")
    @DeleteMapping("delete/{id}")
    public BaseResponse<JSONObject> deleteByID(@PathVariable("id") int id) {
        return damageService.removeById(id) ? setResultSuccess("删除成功！") : setResultError("删除失败！");
    }


    @ApiOperation(value = "更新damageService")
    @DeleteMapping("update")
    public BaseResponse<JSONObject> updateByID(Damage damage) {
        return damageService.updateById(damage) ? setResultSuccess("更新成功！") : setResultError("更新失败！");
    }
}

